package com.yzr.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @description
 * @author: yx-0173
 * @date: 2021-08-24 17:12
 **/
public class Servlet1 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 接收参数
        String username = req.getParameter("username");
        System.out.println("servlet1接收参数 ：" + username);

        // 设置上下文域
        req.setAttribute("key", "ok");

        // 请求转发
        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/WEB-INF/index.html");
        requestDispatcher.forward(req, resp);
    }
}
